home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / comm / tlx322_1.zip / QDHOST.SLT < prev    next >
Text File  |  1994-01-31  |  29KB  |  1,100 lines

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. //   Q D H O S T . S L T
  4. //
  5. //   Copyright (C) 1988-1992 deltaComm Development.
  6. //
  7. //   - Written by Colin Sampaleanu.
  8. //   - Modifications by Jeff Woods, Feb '91, to add help function and support
  9. //     for locked modems.
  10. //   - Modifications by Dan Horn, Nov '92, fixed 'floating' timer bug.
  11. //
  12. //
  13. //   This is a Host Mode for Telix, written as a script file.
  14. //   To configure Host Mode parameters such as passwords, run the 'QDCONFIG'
  15. //   script. That script is run automatically if the Host Mode configuration
  16. //   file 'QDHOST.CNF' is missing.
  17. //
  18. //   This script will only work with Hayes compatible modems, but may be
  19. //   modified for operation with other modems.
  20. //
  21. //////////////////////////////////////////////////////////////////////////////
  22.  
  23. // Parameters which can be configured
  24.  
  25. str pass1[8] = "pass1",                 // The level 1 pass
  26.     pass2[8] = "pass2",                 // The level 2 (Sysop) pass
  27.     shellpass[8] = "shell",             // the pass to enter the Remote Shell
  28.     shutpass[8] = "shut",               // the pass to shut down the Host Mode
  29.     host_downloads[64],                 // where users may download from
  30.     host_uploads[64];                   // where uploaded files go
  31. int direct_connect = 0,
  32.     modem_lock = 0;
  33.  
  34. str current_caller[31],                 // storage of current caller's name
  35.     conn300[] = "CONNECT^M",            // modem result messages for bauds
  36.     conn1200[] = "CONNECT 1200",
  37.     conn2400[] = "CONNECT 2400",
  38.     conn9600[] = "CONNECT 9600",
  39.     conn19200[] = "CONNECT 19200";
  40.  
  41. int finished_caller,                    // set to TRUE when must return to top
  42.     local_mode,                         // set to TRUE when local test mode
  43.     access_level,                       // access level of current caller
  44.     carrier_counts = 1,                 // TRUE if should watch Carrier signal
  45.     already_connected = 0,
  46.     exit_requested = 0,                 // set to TRUE if Sysop has pressed Esc
  47.     connection_lost = 0,                // set to TRUE when carrier lost
  48.     kill_user = 0;                      // set to TRUE when user must be purged
  49.  
  50. int old_scr_chk_key,                    // storage for some system variables
  51.     old_cisb_auto,                      // which we have to modify and put
  52.     old_zmod_auto,                      // back to what they were when done
  53.     old_sound;
  54. str old_down_dir[64],
  55.     old_up_dir[64],
  56.     old_usage_fname[64];
  57.  
  58. //////////////////////////////////////////////////////////////////////////////
  59. //////////////////////////////////////////////////////////////////////////////
  60.  
  61. main()
  62.  
  63. {
  64.  int c;
  65.  
  66.  clear_scr();
  67.  
  68.  if (read_host_config_file() == -1)
  69.   {
  70.    prints("Unable to read QDHOST.CNF...");
  71.    prints("Running QDCONFIG, the Host Mode configuration script.^M^J");
  72.    call("QDCONFIG");
  73.    if (read_host_config_file() == -1)
  74.     {
  75.      prints("Still unable to read QDHOST.CNF. Aborting Host Mode.^M^J");
  76.      return -1;
  77.     }
  78.   }
  79.  
  80.  if (!check_directories())
  81.   {
  82.    prints("Either the upload or download directory as defined in the QDHOST.CNF file");
  83.    prints("doesn't exist. Either create the missing directory with the DOS 'MKDIR'");
  84.    prints("command, or run the QDCONFIG script to redefine what directories to use.");
  85.    prints("Aborting Host Mode.");
  86.    return -1;
  87.   }
  88.  
  89.  old_scr_chk_key = _scr_chk_key;
  90.  _scr_chk_key = 0;
  91.  old_cisb_auto = _cisb_auto;
  92.  _cisb_auto = 0;
  93.  old_zmod_auto = _zmod_auto;
  94.  _zmod_auto = 0;
  95.  old_sound = _sound_on;
  96.  _sound_on = 0;
  97.  old_down_dir = _down_dir;
  98.  _down_dir = host_uploads;   // these are reversed because we are now the Host
  99.  old_up_dir = _up_dir;
  100.  _up_dir = host_downloads;   // these are reversed because we are now the Host
  101.  old_usage_fname = _usage_fname;
  102.  
  103.  usagelog("QDHOST.LOG");
  104.  
  105.  if (direct_connect)
  106.   carrier_counts = 0;
  107.  else
  108.   carrier_counts = 1;
  109.  
  110.  if (!direct_connect && carrier())
  111.   already_connected = 1;
  112.  
  113.  
  114.  while (1)
  115.   {
  116.    if (!direct_connect && !already_connected)
  117.     {
  118.      if (!modem_lock)
  119.         set_cparams(modem_lock, 0, 8, 1);
  120.      delay(3);
  121.      prints("Sending Modem Init string...");
  122.      cputs_tr(_mdm_init_str);
  123.      delay(10);
  124.      prints("Sending Auto-Answer string...");
  125.      cputs_tr(_auto_ans_str);
  126.     }
  127.  
  128.    finished_caller = kill_user = 0;
  129.  
  130.    if (direct_connect)
  131.     carrier_counts = 0;
  132.    else
  133.     carrier_counts = 1;
  134.  
  135.    if (!direct_connect)
  136.     {
  137.      prints("^M^JQDHost Mode: Waiting for call...");
  138.      prints("(Press Esc to exit, or 'L' for local test mode).^M^J");
  139.  
  140.      do
  141.       {
  142.        if (carrier())
  143.         {
  144.          local_mode = 0;
  145.          break;
  146.         }
  147.  
  148.        c = inkey();
  149.        if (c)
  150.         {
  151.          if (c == 27)
  152.           {
  153.            exit_requested = 1;
  154.            break;
  155.           }
  156.          else if (c == 'l' || c == 'L')               // local teswt mode
  157.           {
  158.            prints("Local test mode entered");
  159.            local_mode = 1;
  160.            carrier_counts = 0;
  161.           }
  162.         }
  163.       }
  164.      while (toupper(c) != 'L');
  165.     }
  166.  
  167.    if (!exit_requested)
  168.     {
  169.      prints("Incoming call. Sysop: press Esc to exit, or END to terminate user.");
  170.  
  171.      do_one_caller();
  172.      if ((connection_lost || kill_user) && carrier_counts && carrier())
  173.       hangup();             // make sure nobody sneaks in
  174.     }
  175.    already_connected = 0;
  176.    if (exit_requested)
  177.     {
  178.      if (!carrier() && !direct_connect)
  179.       {
  180.        prints("Sending Modem Init string...");
  181.        cputs_tr(_mdm_init_str);
  182.       }
  183.      _scr_chk_key = old_scr_chk_key;
  184.      _cisb_auto = old_cisb_auto;
  185.      _zmod_auto = old_zmod_auto;
  186.      _sound_on = old_sound;
  187.      _down_dir = old_down_dir;
  188.      _up_dir = old_up_dir;
  189.      prints("^M^JQDHost mode script finished.");
  190.      usagelog("*CLOSE*");
  191.      _usage_fname = old_usage_fname;
  192.      return 1;
  193.     }
  194.   }
  195. }
  196.  
  197. //////////////////////////////////////////////////////////////////////////////
  198.  
  199. HelpOn(int option)
  200.  
  201. {
  202.    if (option == 'H')
  203.     {
  204.      host_send("^M^JHelp on Help^M^J");
  205.      host_send("^M^JTo use the help, simply type the first letter of one of the following:");
  206.      host_send("^M^J^M^J<H>elp <F>iles <T>ype <U>pload <D>ownload <S>hell <C>hat <G>oodbye");
  207.      Host_send("^M^J");
  208.     }
  209.    if (option == 'F')
  210.     {
  211.      host_send("^M^JHelp on Files^M^J");
  212.      host_send("^M^JThe 'Files' option allows the caller to list the files in the");
  213.      host_send("^M^Jcurrent disk directory. The caller must press a key after each");
  214.      host_send("^M^Jscreen. The output is not echoed on the local screen. If the");
  215.      host_send("^M^Jcaller has access level two s/he is prompted for a filespec,");
  216.      host_send("^M^Jwhich may include the * and ? wildcard characters (see your");
  217.      host_send("^M^JDOS manual), so that the contents of other directories than");
  218.      host_send("^M^Jthe 'Host download dir' may be listed.");
  219.      Host_send("^M^J");
  220.     }
  221.    if (option == 'T')
  222.     {
  223.      host_send("^M^JHelp on Type^M^J");
  224.      host_send("^M^JThe 'Type' option allows the caller to view any ASCII file in");
  225.      host_send("^M^Jthe Host Download Directory, or in any directory for access");
  226.      host_send("^M^JLevel 2 callers.   Simply give the name (or full path and name)");
  227.      host_send("^M^Jof the system file you wish to view:    ie. C:\TELIX\TELIX.IMG");
  228.      Host_send("^M^J");
  229.     }
  230.    if (option == 'U')
  231.     {
  232.      host_send("^M^JHelp on Uploading^M^J");
  233.      host_send("^M^JThe 'Upload' option allows the caller to send a file to the");
  234.      host_send("^M^Jhost. The caller is shown the a menu of protocols.   He/she");
  235.      host_send("^M^Jshould select the appropriate protocol by its first letter");
  236.      host_send("^M^J(or 'E' for Ymodem-g). If appropriate the caller is also asked");
  237.      host_send("^M^Jfor the filename.  The transfer is then initiated by QDHOST.  The");
  238.      host_send("^M^Jcaller must then initiate the upload on THEIR side by giving");
  239.      host_send("^M^Jtheir comm program an u